package com.xiaoshuidi.cloud.module.contract.enums.contract;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * 同住人 入住状态
 *
 * @Author Feng
 * @date 2023/7/3
 */
@Getter
@AllArgsConstructor
public enum RoommateStatusEnum {

    PENDING_CHECK_IN(1, "待入住"),
    CHECKED_ID(2, "已入住"),
    RENTED(3, "已退租");
    private Integer code;
    private String msg;


    public static String getMsgByCode(Integer code) {
        if (code == null) {
            return "";
        }
        Optional<String> first = Arrays.stream(RoommateStatusEnum.values()).filter(s -> s.getCode().equals(code)).map(s -> s.getMsg()).findFirst();
        if (first.isPresent()) {
            return first.get();
        }
        return "";
    }
}
